<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/common/commonConfig.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
    <title>系统角色-资源按钮</title>
    <script src="<%=basePath%>component/layout.js"></script>
    <script src="<%=basePath%>component/toolbar.js"></script>
</head>
  
<body onload="bodyOnload()"> 
	<div id="dataObj">
	 <c:if test="${!empty RelationAuthorize}" >
		<table>
			<tr>
				<td>增加</td>
				<td>
					<input style="width:10px" id="c-powerInsert" name="c-powerInsert" type="checkbox" <c:if test="${RelationAuthorize.powerInsert == 1}" >checked="checked"</c:if>  /> 
				</td>
			</tr>
			<tr>	
				<td>修改</td>
				<td>
					<input style="width:10px" id="c-powerUpdate" name="c-powerUpdate" type="checkbox"  <c:if test="${RelationAuthorize.powerUpdate == 1}" >checked="checked"</c:if>	/>  
				</td>
			</tr>
			<tr>   			
				<td>删除</td>
				<td>
					<input style="width:10px"  id="c-powerDelete" name="c-powerDelete" type="checkbox" <c:if test="${RelationAuthorize.powerDelete == 1}" > checked="checked"</c:if>	/> 
				</td>
			</tr>
			<tr>   			
				<td>操作全部单位信息</td>
				<td>
	<input style="width:10px" id="c-operationAll" name="c-operationAll" type="checkbox" onclick="clickOperationAll(this);" <c:if test="${RelationAuthorize.operationAll == 1}" > checked="checked"</c:if> />
	 			</td>
			</tr>
			<tr>   			
				<td>可操作单位的级别</td>
				<td>
	<input  id="c-operationLevel" name="c-operationLevel" value="${RelationAuthorize.operationLevel }"  <c:if test="${RelationAuthorize.operationAll == 1}" >disabled="disabled"</c:if>	/>  
				</td>
			</tr>
		</table>
		<form action="<%=basePath%>system-authorize/RoleResourceBindingAction!updatePowerResourceOfRole.action" method="post">
			<input type="hidden" id="roleResourceRelationAuthorize.resourceId" name="roleResourceRelationAuthorize.resourceId" 
				value="${resourceId }">
			<input type="hidden" id="roleResourceRelationAuthorize.roleSystemId" name="roleResourceRelationAuthorize.roleSystemId"
				value="${roleSystemId }">
			<input type="hidden" id="roleResourceRelationAuthorize.powerInsert" name="roleResourceRelationAuthorize.powerInsert"
				value="${RelationAuthorize.powerInsert }">
			<input type="hidden" id="roleResourceRelationAuthorize.powerUpdate" name="roleResourceRelationAuthorize.powerUpdate"
				value="${RelationAuthorize.powerUpdate }">
			<input type="hidden" id="roleResourceRelationAuthorize.powerDelete" name="roleResourceRelationAuthorize.powerDelete"
				value="${RelationAuthorize.powerDelete }">
			<input type="hidden" id="roleResourceRelationAuthorize.operationAll" name="roleResourceRelationAuthorize.operationAll"
				value="${RelationAuthorize.operationAll }">
			<input type="hidden" id="roleResourceRelationAuthorize.operationLevel" name="roleResourceRelationAuthorize.operationLevel"
				value="${RelationAuthorize.operationLevel }">
		</form>
	</c:if>
	</div>
</body>

<script type="text/javascript">
var dhxLayout = createLayoutNormal('1C',false,true);

function bodyOnload(){
	if('${operateWin}' == 'operateWin'){
		parent.parent.parent.notifyCreater('操作成功');
	}
	configLayout();
}

function configLayout(){
	var a = dhxLayout.cells('a');
	a.hideHeader();
	a.setText('主页面');
	a.fixSize(true, true);
	//validate power of operation
	if(power.getPower() != '' && power.getPowerUpdate() && '${!empty RelationAuthorize}' == 'true')
		createToolbarFromDHXLayoutCell(a,function(toolbar){
		    toolbar.addText("info", 1, "操作:");
		    toolbar.addSeparator("sep1", 2);
		    if(power.getPowerUpdate() && '${!empty RelationAuthorize}' == 'true')toolbar.addButton("update", 3, "提交", "save.gif", "save_dis.gif");
		    toolbar.attachEvent("onClick", function(id) {
		    	if(id == 'update'){
		    		validateBind();
		    	}
		    });
		});
	a.attachObject('dataObj');
}

function validateBind(){
	layoutProgressOn(dhxLayout);
	document.getElementById('roleResourceRelationAuthorize.powerInsert').value=(document.getElementById('c-powerInsert').checked == true ? '1' : '0');
	document.getElementById('roleResourceRelationAuthorize.powerUpdate').value=(document.getElementById('c-powerUpdate').checked == true ? '1' : '0');
	document.getElementById('roleResourceRelationAuthorize.powerDelete').value=(document.getElementById('c-powerDelete').checked == true ? '1' : '0');
	document.getElementById('roleResourceRelationAuthorize.operationAll').value=(document.getElementById('c-operationAll').checked == true ? '1' : '0');
	document.getElementById('roleResourceRelationAuthorize.operationLevel').value=document.getElementById('c-operationLevel').value;
	document.forms[0].submit();
}
	
function clickOperationAll(operationAllCheckboxObj){
	var oa_checked = operationAllCheckboxObj.checked;
	if(oa_checked == true){
		document.getElementById('c-operationLevel').disabled='disabled';
		document.getElementById('c-operationLevel').value='0';
	}else{
		document.getElementById('c-operationLevel').disabled='';
	}
}
</script>

</html>
